Cube.define('Cube.Ajax', {
	implements: 'Cube.data.HttpRequest',
	singleton: true,
	
	request: function(options, scope) {
		if (typeof(options.url) === 'undefined') Cube.Logger.error("[Cube.Ajax.request] requires you to provide an url");
		
		var defaults = {
			type: 'GET',
			async: true,
			cache: false,
			beforeSend: Cube.emptyFn,
			success: Cube.emptyFn
		};
		
		options = this.parseConfig(options, defaults);
		
		this.on({
			requestsuccess: function(response, xhr) {
				options.success.call(scope, response, xhr);
			}
		}, this);
		
		this.create(options.url, options.type, options.async, options.cache);
	}
});